***MALAWI INJECTABLE ADJUSTED CPR

***David Canning and Mahesh Karra, 1-24-24

***STEP 0: SETTING WORKING DIRECTORY
***To use the correct file directory, replace lines 11-12 below to your specific working directory where your files are stored.

version 13

if "`c(username)'"=="mvkarra" {
                global maindir1 "C:\Users\mvkarra\Documents\Harvard 2015-2016\POP CENTER\MALAWI FP INTERVENTION\Publications\INJECTABLES ADJUSTMENT\REPLICATION DATA"
				global maindir2 "C:\Users\mvkarra\Documents\Harvard 2015-2016\POP CENTER\MALAWI FP INTERVENTION\Publications\INJECTABLES ADJUSTMENT\RESULTS"
}
else if "`c(username)'"=="" {
                global maindir1 ""
				global maindir1 ""
}

***OPEN DATASET
use "$maindir1\REPLICATION_DATA_9-19-23.dta", clear

***CHANGE DIRECTORY TO RESULTS
cd "$maindir2"

***INSTALL ESTPOST AND ESTTAB COMMANDS (IF NOT ALREADY INSTALLED)
capture ssc install estout, replace

***DESCRIPTIVE STATISTICS AND TABULATIONS

***TABLE 1
estpost sum curr_use inj_use inj_use_u inj_exp* curr_use_adj inj_use_adj inj_use_adj_u
esttab using KEY_Descriptive_Use.rtf, cells("mean(fmt(3)) sd(fmt(3)) min(fmt(1)) max(fmt(1))") nomtitle nonumber replace

estpost sum duration_cont_mths duration_inj_mths duration_inj_exp_mths date_last_inj
esttab using KEY_Descriptive_Duration.rtf, cells("mean(fmt(3)) sd(fmt(3)) min(fmt(1)) max(fmt(1))") nomtitle nonumber replace

***FIGURE 1 AND 2: HISTOGRAM OF INJECTABLE USE, TIME SINCE LAST INJECTABLE
hist duration_inj_mths, freq color(gs12) lcolor(white) title("Duration of Reported Injectable Use, Months") xtitle("Injectable Use, Months")
graph export Duration_Inj_Mths.png, replace
graph export Duration_Inj_Mths.svg, replace
gr export Duration_Inj_Mths.eps, as(eps) preview(off) replace
!epstopdf Duration_Inj_Mths.eps

hist date_last_inj if date_last_inj < 15, freq color(gs12) lcolor(white) width(1) barwidth(0.9) xlabel(0(3)15) title("Time Since Last Injectable, Months") ///
xtitle("Months") xline(6) xline(3, lpattern(dash)) xline(4, lpattern(shortdash_dot))
graph export Date_Last_Inj.png, replace
graph export Date_Last_Inj.svg, replace
gr export Date_Last_Inj.eps, as(eps) preview(off) replace
!epstopdf Date_Last_Inj.eps
